package com.ks.sgms.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ks.sgms.dao.DepartmentDao;
import com.ks.sgms.dao.ScoreDao;
import com.ks.sgms.entity.Department;
import com.ks.sgms.entity.Score;

@WebServlet("/updateDepartment")
public class UpdateDepartmentServlet extends HttpServlet{
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		Department department = new Department();
		department.major_id = req.getParameter("major_id_up");
		department.major_name = req.getParameter("major_name_up");
		department.department_id = Integer.parseInt(req.getParameter("department_id_up"));

		boolean suc = new DepartmentDao().updateMajor(department);
		if(suc)
			req.getRequestDispatcher("department.jsp").forward(req, resp);	
		else
			req.getRequestDispatcher("department-update.jsp").forward(req, resp);	
	}
}
